package com.web.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class LoginServlet extends HttpServlet{
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException
	
	{
		String user= request.getParameter("user");
		String pass= request.getParameter("password");
		
		if ("admin".equals(user)&&"123".equals(pass)){
			
			responseHtml(response, "login ok");
			
		} else {
			responseHtml(response, "invalid login");
			
		}
		
		
		
	}

	private void responseHtml(HttpServletResponse response, String msg) throws IOException {
		PrintWriter out = response.getWriter();
		out.println("<html>");
		out.println("<body>");
		out.println("<t1>" + msg + "</t1>");
		out.println("</body>");
		out.println("</html>");
		
	}

}
